package cur.nature.component.minio.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConditionalOnProperty( value = {"cur.component.minio.enable"})
public class MinioConfig {

    @Value("${spring.servlet.minio.bucket-id}")
    private String bucketId;

    @Value("${spring.servlet.minio.access-key}")
    private String accessKey;

    @Value("${spring.servlet.minio.secret-key}")
    private String secretKey;

    @Value("${spring.servlet.minio.url}")
    private String url;

    @Value("${spring.servlet.minio.file-path}")
    private String filePath;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder()
                .endpoint(url)
                .credentials(accessKey,secretKey)
                .build();
    }
}


